Strux

A graphical editor for flowcharts

by Andreas Günther

Version 1.1 1.12.93

Contents

1 Introduction 5 1.1 About this Book . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3 Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Getting Started 7 2.1 Hardware Requirements . . . . . . . . . . . . . . . . . . . . 7 2.2 Installation on Hard Disk . . . . . . . . . . . . . . . . . . . 7 2.3 Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Working with Strux 9

3.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.1 Start . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.2 Quit Strux . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.3 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.4 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.5 Loading a Flowchart . . . . . . . . . . . . . . . . . . 10 3.1.6 Representations . . . . . . . . . . . . . . . . . . . . . 11 3.1.7 Selecting a Block . . . . . . . . . . . . . . . . . . . . 11

3.2 The Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.1 Cut . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.2 Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2.3 Paste . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2.5 Marking a Range . . . . . . . . . . . . . . . . . . . . 14 3.2.6 Example . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.7 Loading and Saving Clips . . . . . . . . . . . . . . . 15 3.2.8 Erase . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.2.9 Number of the Clipboard . . . . . . . . . . . . . . . 17

3.3 Creating a Flowchart . . . . . . . . . . . . . . . . . . . . . . 17 3.3.1 New Project . . . . . . . . . . . . . . . . . . . . . . 17 3.3.2 Add New Blocks . . . . . . . . . . . . . . . . . . . . 17

3.4 Modification of the Current Block . . . . . . . . . . . . . . 19 3.4.1 Changing the Text . . . . . . . . . . . . . . . . . . . 19 3.4.2 Changing the Type . . . . . . . . . . . . . . . . . . . 19

3.5 Refinements . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.5.1 Refine Block . . . . . . . . . . . . . . . . . . . . . . 20 3.5.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.5.3 Marking of Refinements . . . . . . . . . . . . . . . . 21 3.5.4 Set Main Refinement . . . . . . . . . . . . . . . . . . 21 3.5.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.5.6 Convert Refinements to “Subroutines” . . . . . . . . 22

3.6 Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.6.1 Loading Strux-files . . . . . . . . . . . . . . . . . . . 23 3.6.2 Loading Sourcecode . . . . . . . . . . . . . . . . . . 23

3.7 Saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.7.1 Saving as Strux-file . . . . . . . . . . . . . . . . . . . 24 3.7.2 Saving as Text . . . . . . . . . . . . . . . . . . . . . 24 3.7.3 Saving as an Image . . . . . . . . . . . . . . . . . . . 24 3.7.4 Save by Last Filename . . . . . . . . . . . . . . . . . 24 3.7.5 Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.8 Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.8.1 Print All . . . . . . . . . . . . . . . . . . . . . . . . 25 3.8.2 Print Displayed Flowchart . . . . . . . . . . . . . . . 26 3.8.3 Print Clip . . . . . . . . . . . . . . . . . . . . . . . . 26 3.8.4 Quality . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.9 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.9.1 Diagram Settings . . . . . . . . . . . . . . . . . . . . 26 3.9.2 Screen Settings . . . . . . . . . . . . . . . . . . . . . 27 3.9.3 Program Settings. . . . . . . . . . . . . . . . . . . . . 29 3.9.4 Close Workbench ? . . . . . . . . . . . . . . . . . . . 30 3.9.5 Open Settings . . . . . . . . . . . . . . . . . . . . . . 30 3.9.6 Save Settings . . . . . . . . . . . . . . . . . . . . . . 30

3.10 Translation Tables . . . . . . . . . . . . . . . . . . . . . . . 31 3.10.1 Creating a Translation Table . . . . . . . . . . . . . 31 3.10.2 Example: Translation of a Loop . . . . . . . . . . . . 32

4 Tutorial 35 4.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.2 Developing the Flowchart . . . . . . . . . . . . . . . . . . . 35 4.3 Creating a C Program . . . . . . . . . . . . . . . . . . . . . 39 4.4 Creating a Pascal Program . . . . . . . . . . . . . . . . . . 42 5 Miscellaneous 45

5.1 Title Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 5.1.1 … of the Window . . . . . . . . . . . . . . . . . . . 45 5.1.2 … of the Screen . . . . . . . . . . . . . . . . . . . . 45

5.2 Tooltypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 5.3 Starting from the Shell . . . . . . . . . . . . . . . . . . . . . 46 5.4 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.5 License Agreement . . . . . . . . . . . . . . . . . . . . . . . 48

A Keyboard Shortcuts 49

B Graphical Representations 51 4 CONTENTS

Chapter 1

Introduction

To get from an idea to a complete program, several steps are necessary:

• specification of the idea (exact definition of desired functions and requirements)

• design of the program (development of an algorithm and the structure of the program)

• implementation (conversion into any programming language and at last into an executable program)

The flowchart editor Strux makes it easy to design the program structure and helps with the step of the implementation in any programming language. First, you can design the structure as a flowchart conveniently on your screen. Then, you can save your design as a sourcecode “skeleton” which you can easily expand to an executable program.

Many programmers skip the design phase and try to implement the program at once. However, this method brings you quickly into chaos and may lead to errors. On the other hand, if you design your program structure with Strux first, you will not loose the survey, your programs will have less bugs and also get some comments by the way.

Additionally, flowcharts are perfect methods for the documentation and explanation of programs and algorithms, because they are independent of any programming language and can be clearly understood. (Even for handling problems not associated with computers, you need algorithms.)

To understand an existing, perhaps uncommented program, it is helpful to recognize the program structure. Therefore, Strux gives you the possibility to read sourcecode written in Pascal or C and display it as a flowchart.

1.1 About this Book

Basic knowledge in using the Amiga and its graphical user interface is assumed, especially for topics which are explained detailed in your Workbench manual (e.g. filerequesters).

The structure of this manual is as follows:

After describing the installation in chapter 2, some basic operations are explained (section 3.1) They are needed to execute the examples in the following sections. The following sections of chapter 3 explain all program functions. They are sorted by topic. Short examples are inserted to support the explanations. In chapter 4, the path from an idea via a flowchart to the executable program is presented step by step as a tutorial.

1.2 Registration

You should immediately return the enclosed registration card. You will be a registered user of Strux and have the following advantages:

• You will immediately be informed about updates and have the possibility to upgrade to new versions for a low price.

• When you have problems or questions about Strux, you will get free help. (see 5.4)

When you pass Strux to another person (e.g. sell it), do not forget to change your registration to the new user of Strux.

1.3 Trademarks

Please notice that some names mentioned in this manual are registered trademarks:

• Amiga, Kickstart and Workbench are registered trademarks of Commodore Amiga, Inc.

• CygnusEd is a registered trademark of CygnusSoft Software

Getting Started

2.1 Hardware Requirements

Strux is executable on every Commodore-Amiga with at least 512 kByte RAM and Kickstart/Workbench Version 2.04 or higher.

2.2 Installation on Hard Disk

Simply drag the drawer with the name “Strux english” from the Struxdiskette to the desired place on your hard disk. You may then rename the drawer to “Strux” or any other name.

Strux needs about 200 kBytes free disk space.

2.3 Backup

You have the right to make one backup copy of Strux (see 5.5). To keep the installation and use of Strux as simple as possible, no copy protection is installed. Moreover, there is no copy protection which could not be cracked after a short time.

Apart from a simple installation, this gives you the advantage of making a backup easily. You can use a copy program or the Workbench. If you do not know how to copy a disk, please refer to your Workbench manual. After backing up your disk, you should store your original disk in a safe place.

When you have installed Strux on your hard disk, you also do not need your original disk any more.

8 CHAPTER 2. GETTING STARTED

Working with Strux

3.1 Basics

In this section, some basic things will be explained. These things are assumed to be known in the next sections and you need them to execute the given examples.

3.1.1 Start

First open the Strux drawer. You start the program by double-clicking the icon named “Strux”. After that, a window appears on the Workbench. This is the working area of Strux, where the flowcharts are displayed.

By clicking on the zoom gadget (in the upper right border of the window), the size of the window will be adjusted to the visible area of your screen.

3.1.2 Quit Strux

To quit the program, you can either select the menu item Project ≫ Quit Strux… or click on the close gadget of the Strux window. Before finally exiting, you will be asked for a confirmation. If the currently edited flowchart is unsaved, you will be informed and get the chance to save it before exiting Strux.

3.1.3 Help

Strux contains a built in help function which can be popped up at any time. There is help available for any menu item, any window and some special terms.

To get help, do the following:

Help for menus or menu items: Select the menu item, but keep the right mouse button pressed and press the Help key.

Help for windows: While the window is active, just press the Help key.

Explanations of special terms: Click on the button named “Keywords” in the help window and select the desired term.

A window appears showing the help text. You can scroll the text with the scroll bar on the right hand side. While the help window is displayed, you can continue to work with Strux. The help window can be closed at any time by clicking on its close gadget.

3.1.4 Menus

All functions can be reached using the menus. Most functions have also a corresponding key to allow fluent work. The keys are indicated in the menus and have to be pressed together with the right “Amiga”-key ( A ). Appendix A contains a complete list of all menu shortcuts. In the windows, you can select the gadgets that have one underlined character by pressing the appropriate key. You can browse through lists with the arrow keys.

3.1.5 Loading a Flowchart

Before proceeding with the next sections of this introduction, the loading of a flowchart will be explained first. To open one, select the menu item Project ≫ Open ≫ Strux-file. . .. A standard filerequester appears. Now, you can choose a flowchart and select the ”Open” button. Then, the flowchart will be loaded and displayed.

Example: Now you can open the file “textviewer” in the drawer “Examples”. This flowchart will be used in the examples in the next sections. It is a design for a program to load a text from disk and show or print it. The diagram is shown in figure 3.1 as a Nassi-Shneiderman flowchart.

Figure 3.1: Example “textviewer”

3.1.6 Representations

A flowchart can be displayed in three different representations: as a “normal” flowchart, as a Nassi-Shneiderman flowchart or as pseudocode. You can switch between these representations at any time with the menu item Settings ≫ Diagram. . .. A window appears where you can select the desired representation. Close the window with ”Use”.

Nassi-Shneiderman: The diagram is shown according to Nassi-Shneiderman.

Flowchart: This is the common graphical representation of a flowchart.

Pseudocode: The project is shown as a textual representation in a pseudo language. The different block types are described by keywords and the structure by indents. The keywords are the same as appear in the menu “Add” (see 3.3.2).

If the size of a diagram extends the size of the Strux window, only a part of it is displayed. You can move the displayed section with the scrollbars in the right and bottom borders of the window.

3.1.7 Selecting a Block

One block in the diagram is marked by reverse colors. This is the “current block”, it corresponds to the cursor in a word processor. E.g. new blocks are always inserted below this block, the cut or copy operations refer to this block etc.

To select a block (make it the “current block”) you may simply click on it with the mouse. In blocks like selections or loops, the whole block with all branches is marked and taken as the current block.

You also have the possibility to use the arrow keys to navigate through the diagram. The keys have the following effects:

without ⇑ or Ctrl key:

↑ jump up one block

↓ jump down one block

→ jump into branch or loop body

← jump up one block

with ⇑ key:

↑ jump to the next higher construct (e.g. from a loop body back to the loop block itself)

↓ jump to the bottom block of a branch or loop body

→ jump to the last case (e.g. in a ”Case” construct)

mit Ctrl key:

↑ jump to the top block of the displayed flowchart

↓ jump to the last block of the displayed flowchart

3.2 The Clipboard

Like in word processors, you can cut or copy parts of the flowchart and paste them somewhere else. The most recent cut part is kept in the clipboard until something new is cut or copied.

The text of the cut blocks can also be pasted by other programs which support the clipboard.

3.2.1 Cut

menu item: Edit ≫ Cut The current block or the marked range (see 3.2.5) is deleted in the flowchart and put into the clipboard. The former contents of the clipboard will be lost!

All main refinements are cut, these are the ones which are displayed in a different color (see 3.5).

3.2.2 Copy

menu item: Edit ≫ Copy The current block is put into the clipboard, but also remains in the flowchart. The former contents of the clipboard will be lost !

All main refinements are copied, these are the ones which are displayed in a different color (see 3.5).

3.2.3 Paste

menu item: Edit ≫ Paste The contents of the clipboard are inserted into the flowchart after the current block. The clipboard remains unchanged and its contents can be inserted at different points.

3.2.4 Example

In the flowchart “textviewer”, the screen should be cleared before showing the text. To perform this change, we execute the following steps:

1. First, we select “clear screen” as the current block by clicking on it with the mouse.

2. We select the menu item Edit ≫ Copy. Now, the block “clear screen” is put into the clipboard.

3. The block “clear screen” should be inserted between the blocks “load textfile” and “show text”. First, we click on the block “load textfile” to select it as the current block.

4. Then we select the menu item Edit ≫ Paste to insert the block “clear screen”.

Additionally, the screen should be cleared before printing the error message.

1. We select the block “Error: "no text loaded" ”.

2. Then we jump up one block with the ↑ key. The block is shown as a slim bar, because this is the “root” of the “else” part.

3. The block “clear screen”is still remaining in the clipboard. To insert it once again, we select the menu item Edit ≫ Paste. The block will be inserted before the block “Error: "no text loaded" ”.

The modified flowchart is shown in figure 3.2.

Figure 3.2: Result of the first change of the example “textviewer”

3.2.5 Marking a Range

menu item: Edit ≫ Mark Range To cut or copy several blocks at once, a range has to be marked. To do this, you select the first block of the range and then select this menu item. Then you choose the last block of the range with the mouse or the keyboard.

Another way of marking a range is to select the first block with the mouse and moving the mouse to the last block of the range while keeping the left mouse button pressed.

A range can be unmarked by either selecting this menu item again, clicking with the mouse on a block above the range or clicking outside the diagram.

While a range is marked, a “M” is displayed in the title bar of the screen.

3.2.6 Example

In the example flowchart “textviewer”, the text should be loaded and showed before being printed. To perform the changes, we execute the following steps:

1. We click on the block “print text”.

2. Then we select the menu item Edit ≫ Copy. Now, the block is in the clipboard.

3. The copied block should be attached to the block “print” (one case of the “select of… ” block), because we want to erase the test whether the text is loaded or not. Therefore we click on the block “print” and select the menu item Edit ≫ Paste.

4. We click on the block “text loaded ?” and see that the two branches are included into the current block.

5. We select the menu item Edit ≫ Cut. The current block is deleted, however it is still in the clipboard. As this block is not needed any longer^{1}, we can cut the blocks for loading and viewing the text and insert them before “print text”.

6. So, we click on the block “read name of textfile”. This is the start of a range to be marked.

7. We select the menu item Edit ≫ Mark Range to declare the current block as the start of the range. In the title bar of the screen, a “M” appears to indicate that you are marking a range.

8. The block “show text” should be the end of the range, so we click on it. You see that the range is marked with a different color.

9. To copy this range into the clipboard, we select the menu item Edit ≫ Copy. The marking will be turned off and we can continue normal work.

10. We click on the block “print”. This is a case of the “select of… ” block. It can be treated as any other block.

11. With the menu item Edit ≫ Paste, we insert the copied range at the desired point.

The result is presented in figure 3.3. This example should illustrate the use of the clipboard. Later (in 3.5), we

will see how whole ranges can be summarized under one title (refinements), which is more elegant and helps you to keep the survey over your project.

3.2.7 Loading and Saving Clips

The contents of the clipboard (the clips) can be saved to disk. In the submenu Edit ≫ Save Clip As, there are three different methods of saving a clip:

as Strux-file: The clip will be saved in a format that allows the complete restauration of the flowchart with Strux (either with Project ≫ Open ≫ Strux-file… or with Edit ≫ Open Clip. . ..

1You could work with the menu item Edit ≫ Erase, but it is safer to use Edit ≫ Cut, because the cut part is still in the clipboard and can be reinserted if necessary.

Figure 3.3: Result of the second change of the example “textviewer”

as text: The clip will be saved as ASCII-text. For the translation of the flowchart into text, the previously chosen translation table is used (see 3.10.1). So you have the possibility to save a clip in any programming language.

as image: The clip is saved as an image in IFF-ILBM format. Then it can be edited with any paint program or used with DTP programs or word processors.

A file can also be loaded into the clipboard to concatenate two or more flowcharts. Or you can create a library of parts used in several projects and insert them easily into each new flowchart.

The loading can be performed with the menu item Edit ≫ Open Clip. . .. The flowcharts have to be saved in Strux-format (see 3.7.1).

3.2.8 Erase

With the menu item Edit ≫ Erase, you can erase a block or a range. All main refinements of this block or range are erased, too (see 3.5). The erased parts are irretrievably lost. So you should better use the funktion Edit ≫ Cut, because the cut parts are still in the clipboard then.

The erase function can be useful, if the contents of the clipboard should be preserved.

3.2.9 Number of the Clipboard

There are 256 different clipboard units with the numbers from 0 to 255. Normally, all programs use the clipboard unit with the number zero to exchange data among each other. If you do not want this or interference with other programs should be avoided, you can change the number. (menu item Settings ≫ Program…, see 3.9.3)

3.3 Creating a Flowchart

3.3.1 New Project

To clear a flowchart, the menu item Project ≫ New… has to be selected. To prevent you from erasing an unsaved flowchart by mistake, you have to confirm this command. When you select “no”, nothing happens, when you select “yes”, the diagram is irretrievably lost and an empty working area appears. Now, a new flowchart can be created.

In the upper left corner, the current block appears as a flat bar (in pseudocode representation as a star). This is the “root” of the diagram.

3.3.2 Add New Blocks

To add a new block to a flowchart, select the desired type of the block from the menu Add. In most cases a requester appears that asks you for the text of the block(s). If no text is typed in, “???” will be taken to remind you that a text is missing here. If you choose “Cancel”, the block will not be generated. When selecting “Use” or hitting the return key, the new block will be inserted below the current block.

Some blocks with different types are represented by the same graphical symbol. Only in pseudocode the different types can be distinguished by different keywords. However, when saving the flowchart as text, it is important to have chosen the proper blocks, because the blocks are translated differently.

The following types can be used:

Action : A simple action (imperative construct) will be inserted below the current block. It is represented by a rectangle.

If Then : A simple decision (monadic selective) will be inserted below the current block. You have to specify the text for the condition and the action in the “then” branch. The “else” branch can be added later with the menu item Add ≫ Default/Else. . ..

If Then Else : A decision where one of two branches is taken (dyadic selective) will be inserted below the current block. To both branches, an action is attached. The “else” branch can be erased later.

Select of : A decision with a choice of several branches (multiple exclusive selective) will be inserted below the current block. First, you have to type in the text for the decision, then the text for the first case. An action will be added to the first branch. More branches can be added with the menu item Add ≫ Case. With Add ≫ Default/Else, a branch will be added, which is executed when no case is taken.

Case : An additional branch with another condition will be added to a “select of ” block. You will be asked for the text of the case. An action will be added.

Default/Else : A “default” branch will be added to a “select” block, this is a branch that will be executed when none of the given cases is taken. Or an “Else” branch will be added to an “if” block. In either case, an action will be added.

While : A loop will be inserted below the current block (pre-tested iteration). You have to specify the text for the loop construct; an action will be added.

Repeat Until : A loop will be inserted below the current block (posttested iteration). You have to specify the text for the loop construct; an action will be added.

For ... Repeat : A count loop will be inserted below the current block. You have to specify the text for the loop construct; an action will be added.

Repeat Forever : An endless loop will be inserted below the current block. As the loop body, an action will be inserted.

Exit : A command to exit a loop will be inserted below the current block. (termination)

Subroutine : A subroutine call will be inserted below the current block.

Program : The title of the program or a connection to other flowcharts will be inserted below the current block. (terminator, connector) In Nassi-Shneiderman flowcharts, such a symbol is not defined. This type of block will be represented by a borderless rectangle there.

Input : An input (manual operation) will be inserted below the current block. The graphical representation is the same as for the type “Output”, but both types are translated differently when saving the flowchart as text.

Output : An output (manual operation) will be inserted below the current block. The graphical representation is the same as for the type “Input”, but both types are translated differently when saving the flowchart as text.

Parallel : A parallel processing of several branches (processes) will be inserted below the current block (parallel construct). For the first process, an action is inserted, more processes can be added by the menu item Add ≫ Process. . ..

Process : Another branch will be added to a parallel construct.

In appendix B, the graphical representations for all the different types are shown for all three types of flowcharts.

3.4 Modification of the Current Block

You can modify the text and the type of the current block.

3.4.1 Changing the Text

menu item: Edit ≫ Modify ≫ Text… A requester appears showing the text of the block which may be edited. After terminating the input with the return key or selecting ”Use”, the new text will be written into the block. However, when you select ”Cancel”, the old text remains.

Hint: “right Amiga key” ( A ) and X clears the text field.

3.4.2 Changing the Type

menu item: Edit ≫ Modify ≫ Type… A window appears showing a list of all possible types this block can be changed to. If a new type and ”Use” is selected, the type of the current block will be set to the selected one. When you select ”Cancel”, the block will keep its type. The conversion will be done regardless of the logical correctness. E.g. you have to change the text for the loop condition when changing between “while” and “repeat” loops.

Figure 3.4: Refinement of the block “load textfile” in the flowchart “textviewer”.

3.5 Refinements

To design a clearly structured flowchart, you can use refinements. With this method, you can define any block more detailed by a further flowchart.

Example: If a block named “load file from disk” appears in a flowchart, the text contains all information needed at this point to understand its task. The loading of the file however includes several steps (open the file, read it, close it, error handling etc.), which can be defined in a refinement and are invisible from the currently displayed flowchart.

You may also use one refinement at different points in the flowchart.

3.5.1 Refine Block

To refine the current block, select the menu item Refinements ≫ Refine Block. A new flowchart appears on the screen with the name of the refined block as the title. You can edit this flowchart with all the known functions including further refinements. If a block already has a refinement, you can get into its refinement with a double click on the block. A refined block is shown in bold letters if the menu option Refinements ≫ Show ? is selected.

With the menu item Refinements ≫ Higher Level you can get back to the block that has been refined. By clicking on the top border of the displayed flowchart (not the window border), you also get back to the higher level.

With the menu item Refinements ≫ Top Level, you immediately get to the top level of the flowchart.

3.5.2 Example

The method of refining blocks should be illustrated with the example of the “textviewer”. First, you should load the flowchart “textviewer” as described in 3.1.5. Now, the block “load textfile” should be refined with the flowchart shown in figure 3.4. The following steps are necessary:

1. First, we click on the block “load textfile” to select it as the current block.

2. Then we select the menu item Refinements ≫ Refine Block. An empty working area appears with the title “load textfile”. Here, we will specify this action more precisely. This will be done by performing the next three steps.

3. Menu item Add ≫ Action. As text, we type “open file”. The block “open file” appears.

4. Menu item Add ≫ Action. As text, we type “read file”. The block “read file” appears.

5. Menu item Add ≫ Action. As text, we type “close file”. The block “close file” appears.

6. To get back to the previous flowchart, we select the menu item Refinements ≫ Higher Level.

(This example is continued in 3.5.5.)

3.5.3 Marking of Refinements

With the menu item Refinements ≫ Show ? you can select whether all refined blocks should be marked or not. All refined blocks are marked by showing their texts in bold letters. This has the advantage of clearly seeing which blocks have refinements.

One refinement can be used for several blocks with the same name while the flowchart of the refinement exists only once and is attached to exactly one block. This block is called the “main refinement” and its text is written in another color. Only operations done with this block (Cut, Copy, Paste etc.) have influence on the refinement. If you perform an operation on a block with only boldface text, it has no effect on the refinement !

If two blocks get the same text by changing a block’s text, but have different refinements, the ending “ 2” will be attached to avoid confusion.

3.5.4 Set Main Refinement

With the menu item Refinements ≫ Set Main Refinement, you can attach the flowchart of the refinement to the current block.

This may be necessary before executing an operation that also concerns the refinements. E.g. if the refinement should not be copied, because it would be duplicated, you should put the main refinement outside the copied range.

3.5.5 Example

(Continuation of the last example)

First, the marking of the refinements should be switched on. If the menu item Refinements ≫ Show ? is already selected (the checkmark is displayed), the marking is active. If not, switch it on.

The action “load textfile” should be inserted after “print”.

We click on the block “print” and select the menu item Add ≫ Action. We enter the text “load textfile”. After the action is inserted, we see that the text is printed in boldface to show, that there is a refinement for this block.

Now, we want to verify, if the refinement of the new block is the same as the one of the other block named “load textfile”:

1. We select the menu item Refinement ≫ Refine Block and will see the same refinement that we created (in the previous example).

2. Now, we will modify this refinement. To do so, we click on the block “close file” and select the menu item Add ≫ Output. We type in the text “write "ok" on screen”.

3. By selecting the menu item Refinements ≫ Higher Level, we get back to our main program. We see, that the current block has become the main refinement.

4. We click on the other block “load textfile”. As this one is marked only with boldface text, it is not the main refinement.

5. Now, we go into this block’s refinement by selecting the menu item Refinements ≫ Refine Block. We recognize the just performed change to the refinement, which proves that this is the same flowchart.

3.5.6 Convert Refinements to “Subroutines”

As refined blocks are often used as subroutines, this conversion can be done automatically.

The representation of a refined block as a “subroutine” has the advantage that these blocks are converted differently when saving the flowchart as text. (E.g. they will be converted to procedure calls)

To convert each refined block of type “action”, “input” or “output” automatically to a block of type “subroutine”, the menu item Refinements ≫ to Subroutine ≫ Automatically ? must be switched on (marked with a checkmark). All blocks that are refined so far keep their types until you climb down into their refinements.

To convert all refined blocks of a flowchart into “subroutines”, the menu item Refinements ≫ to Subroutine ≫ Change All can be used. Please note, that the conversion is only done with blocks of type “action”, “input” or “output”. All other blocks keep their type.

3.6 Loading

3.6.1 Loading Strux-files

The loading of flowcharts in Strux-format with the menu item Project ≫ Open ≫ Strux-file has been explained in 3.1.5.

Another possibility to load flowcharts easily exists when the Strux window is on the workbench. In this case, the icon of the flowchart can be dragged over the Strux window and be dropped there. Then, it will be loaded and displayed.

A third possibility is to double click the icon of a flowchart. Strux will be started and the selected flowchart will be loaded immediately.

Further you may specify a flowchart with the tooltypes of the Strux icon, which will be loaded every time you start Strux (see 5.2).

3.6.2 Loading Sourcecode

There is also the possibility to load sourcecode (in Pascal or C) as a textfile and convert it into a flowchart. This flowchart can be processed as usual.

First, select the menu item Project ≫ Open ≫ Text. . .. A filerequester appears where you can select the source file. Then, you will be asked for the language of the source. The text will be loaded now and a requester appears, in which all parts of the program (procedures and functions) are listed. You can select the part of the program to be loaded. The top item of this list is the main part of the program if there is one.

The code has to be syntactically correct, otherwise it cannot be converted.

Procedures and functions are converted to refinements. Some information (e.g. declarations of variables) will be lost, but the intention of this function is to analyze the structure of the program.

3.7 Saving

A flowchart can be saved to disk in three different formats: as a Strux-file, as text or as an image. The name must be specified in a filerequester. You can define the drawers that are usually used for saving in the “program settings” (see 3.9.3). These path settings can be saved and are used each time you start Strux. Of course, you can change the path in the filerequester appearing each time you load a flowchart.

3.7.1 Saving as Strux-file

menu item: Project ≫ Save As ≫ Strux-file The flowchart is saved in a way that allows its complete reconstruction. A diagram saved with this menu item can be reopened by selecting Project ≫ Open ≫ Strux-file… or Edit ≫ Open Clip. . ..

3.7.2 Saving as Text

menu item: Project ≫ Save As ≫ Text… The diagram will be saved as a textfile in plain ASCII format. The conversion of the different types of blocks can be defined in a translation table (see 3.10.1). With this feature, you have the possibility to save the flowchart in any programming language. A “skeleton” of the sourcecode is created, which consists of the program’s structure.

The creation and loading of translation tables is explained in 3.10.1. If no translation table has been specified yet, you get the possibility to load one now.

An example how to create an executable program from a flowchart is presented in chapter 4.

3.7.3 Saving as an Image

menu item: Project ≫ Save As ≫ Image… The flowchart is saved as an image in IFF-ILBM format. Then, it can be edited with a paint program or loaded into a word processor.

Please note that only the displayed flowchart is saved. Existing refinements have to be saved seperately.

3.7.4 Save by Last Filename

menu item: Project ≫ Save If a flowchart should be saved by the same name it was loaded by, you

Figure 3.5: Icons for Strux-files, texts and images

may use this menu item. Normally, no filerequester appears. Only when the diagram has not got a name yet (because it has not been saved yet), a filerequester appears. The flowchart is always saved in Strux-format.

3.7.5 Icons

Usually, icons are generated for all saved files, so you can handle them easily on the Workbench. The look of the icons depends on the type of file (Strux-file, text or image), see figure 3.5^{2}. It is also possible to turn off the generation of icons. Whether an icon will be generated or not depends on the state of the menu item Settings ≫ Create Icons ?. If this item is marked with a checkmark, icons will be generated.

3.8 Printing

When printing a flowchart, the settings made with the “Preferences” programs on the Workbench are used. While printing a diagram, a window is displayed where you can stop the printing.

3.8.1 Print All

menu item: Project ≫ Print ≫ All The entire flowchart with all refinements is printed. Above each flowchart, the text of the refined block is printed as a title.

2When saving the flowchart in Strux-format, the actual name of the Strux program with the complete path is taken as the default tool. So, the icon can be dragged in any drawer without loosing the possibility to start Strux by double clicking on the flowchart icon. However, if you move the Strux program itself into another drawer, the default tool entries of all previously saved flowcharts will be wrong.

3.8.2 Print Displayed Flowchart

menu item: Project ≫ Print ≫ Displayed The currently displayed flowchart (without refinements) is printed.

3.8.3 Print Clip

menu item: Project ≫ Print ≫ Clip The contents of the clipboard is printed with all refinements.

3.8.4 Quality

The diagram is printed exactly as it is displayed. Therefore, before printing the diagram, a large font should be selected (see 3.9.1). As the printer has a higher resolution, the printing quality gets better.

The marking of refinements (boldface text or different colors, see 3.5.3) is printed, too. If this is not desired, you should turn it off (menu item: Refinements ≫ Show ?).

3.9 Settings

To adjust the program to the used hardware and your personal requirements, there is the Settings menu. All settings can be saved, so that Strux uses automatically these settings each time you start the program. You may also save different settings and open them individually. This can be useful when several persons work with Strux.

3.9.1 Diagram Settings

menu item: Settings ≫ Diagram A requester appears where all settings concerning the rendering of the diagram can be made.

Show As: Here you can select the graphical representation of the diagram.

Nassi-Shneiderman: Graphical representation according to Nassi-Shneiderman.

Flowchart: The common graphical representation of a flowchart.

Pseudocode: A textual representation in a pseudo-language, where the different types are described by keywords and the structure by indents.

Font: The selected font for each of the three representations is shown. By clicking on the corresponding “select… ” button, you can choose the font in a fontrequester.

Save: The settings made in this requester are saved and used. The requester will be closed.

Use: The settings are used but not saved. They will be lost when you quit Strux. The requester will be closed.

Cancel: The old settings are preserved, no change is carried out. The requester will be closed.

The close gadget has the same meaning as the “Cancel” button.

3.9.2 Screen Settings

menu item: Settings ≫ Screen A requester appears where you can define the screen on which you work with Strux. You can either choose an already opened public screen or open an own screen. A “public screen” is a screen opened by another program; every other program can open its windows there. Each public screen has an individual name. This name is not the text printed in the title bar of the window. The name of a public screen is given in the documentation for a program or in its menu item Project ≫ About. . .. However, it is not necessary to look up there as Strux is presenting a list of all currently opened public screens in this requester.

The gadgets have the following meanings:

Screen: A list of all currently opened public screens is shown. Here you can choose any screen. Default is the screen which Strux is currently running on.

Own Screen: When selecting this button, Strux will open an own public screen and open its window there. The selection of the above list has no effect in this case. The opened screen is public, so other programs can open their windows here. The name of the screen is displayed when you select the menu item Project ≫ About. . .. The appearance of the screen can be defined in the requesters appearing when you hit one of the buttons “Display Mode… ”, “Font… ” or “Palette… ”.

Display Mode…: A screenmode requester appears (see 3.9.2). There you can define the mode of your own screen.

Font…: You can select the font for your screen in a fontrequester. All menus and windows on your screen will use this font.

Palette…: The colors of the screen can be defined (see 3.9.2). This is only possible when Strux is already running on an own screen.

Save: The settings made in this requester are saved and used. If you have defined a new screen, that screen will be opened and used. This requester will be closed. The next time you start Strux, the new settings will be used as default.

Use: The settings are used but not saved. They will be lost when you quit Strux. If you have defined a new screen, that screen will be opened and used. This requester will be closed.

Cancel: The old settings are preserved, no change is carried out. This requester will be closed.

The close gadget has the same meaning as the “Cancel” button.

Display Mode Settings

This requester appears when you select the “Display Mode… ” button in the screen settings window. Here, you can define the Mode and the size of the Strux screen. Detailed information about the different display modes can be found in the Workbench manual.

Mode list: In the upper part of the window there is a list of all available display modes. You can select any mode from this list.

Width and height: The size of the screen can be set here. The width and height can be chosen freely as long as the width is greater than 640 and the height is greater than 200 pixels. If the “Default” gadget is selected, the standard size of the selected display mode will be taken.

Default: If this gadget is selected (is marked with a checkmark), the standard size of the selected display mode will be taken for the width and height fields.

Auto Scroll: With this gadget you can select if the visible size of the screen should scroll automatically when you reach its border with the mouse pointer.

OK: This confirms the selection and the requester will be closed.

Cancel: The old settings are preserved. Hitting the close gadget has the same effect.

Adjust colors

Here, you can set the color palette for your own screen. This requester appears when you select the “Palette… ” button in the screen settings window.

Color: In the upper part of the requester you can choose the color to be changed.

Red, Green and Blue: With these sliders you can adjust the red, green and blue portion of the selected color. The effect is immediately visible, so the effect of changing a color can be directly verified.

Workbench colors: By selecting this button, the color settings from the Workbench are taken.

OK: This confirms the selection and takes the colors.

Cancel: The old colors are preserved.

3.9.3 Program Settings…

A window appears where all general settings for Strux can be made. These are:

Paths: The default paths used for saving and opening Strux-files, texts or images are shown. They can be changed by clicking on the appropriate “select… ” buttons.

Refinements: The states of the checkmarks for the menu items Show ? and to Subroutine ≫ Automatically ? in the Refinements menu can be set. (see 3.5.3 resp. 3.5.6)

Other: The states of the checkmarks for the items Workbench ? and Create Icons ? in the Settings menu can be set. (see 3.9.4 bzw. 3.7.5)

Clipboard unit: The number of the clipboard unit used for cut, copy and paste operations can be set here. Normally all programs use unit zero, so they can exchange data. If you do not want this, you can change the number. (see also 3.2.9)

Save: The settings made in this requester are saved and used.

Use: The settings are used but not saved. They will be lost when you quit Strux.

Cancel: The old settings are preserved, no change is carried out. The close gadget has the same meaning as the “Cancel” button.

3.9.4 Close Workbench ?

menu item: Settings ≫ Workbench ? You can select whether the Workbench screen should be open or close. If this item is selected (the checkmark appears), the program tries to open the Workbench screen (if it is not already open). Otherwise it tries to close it. If the program does not succeed in closing the screen (e.g. because other programs opened their windows on it), a requester appears reporting the failure.

The Workbench may be closed to have more free memory available.

3.9.5 Open Settings

menu item: Settings ≫ Open Settings… A previously saved setting can be loaded and restored.

A filerequester appears where you can select a settings file. Only files with the ending “.prefs” are shown, so you can easily find your settings files. The selected settings are loaded and the program will change all settings to the new ones.

When starting Strux, the settings are read from the file “Strux.prefs”. By opening this settings file, you get back your startup settings.

3.9.6 Save Settings

by old name

menu item: Settings ≫ Save All settings are saved to disk. The name of the last settings file you loaded is used. After starting Strux, this is the name “Strux.prefs”.

by new name

All settings are saved to disk.

A filerequester appears where you can select the name of your settings to be saved. The name should end with “.prefs” in order to find the settings easily.

When starting Strux, the settings are read from the file “Strux.prefs”. So, if you save your settings with this name, Strux will start the next time with exactly these settings and you can work in your personal environment.

The following settings are saved:

• name of the used public screen

• whether an own screen is used or not • size, display mode, colors and font of your own screen

• size and position of the Strux window

• type of the graphical representation of the flowchart

• the fonts used for the different representations

• states of the menu items which can be toggled

• number of the clipboard unit

• name of the translation table

3.10 Translation Tables

3.10.1 Creating a Translation Table

menu item: Settings ≫ Translation Table A translation table is required when saving the flowchart as text. In this table, all conversions of the different types of blocks into text are defined.

A window appears where you can create and edit such a table.

Table: In the upper part of the window, the name of the currently used translation table is displayed.

Below, there is a list showing the translation of each type of block. After clicking on an item, you can edit it in the string gadget which is located below the table.

Spaces to “ ”: You can select if space characters should be converted into underscore characters (“ ”). You can either treat all texts like this, only texts of subroutines or none. This option is useful with names that consist of more than one word, because they can be used directly as procedure names.

New: All table entries are cleared.

Save As…: The translation table is saved to disk. The name has to be specified in a filerequester.

Open…: A translation table can be loaded from disk. The name has to be specified in a filerequester.

Save: The table is saved by the name displayed in the top line of this window and the name of the table is saved as the default setting. So, Strux will use this table each time you start it from now on.

Use: The table is used, but will be lost when you quit Strux (unless you have saved it with the “Save As… ” button).

Cancel: The old table is kept and the window will be closed.

To define the translations of the different program constructs, there are several control characters:

%n : start new line
%t : text of the block
%bn : corresponding branch (e.g. the body of a loop or

a “then” branch), where n is the number of characters by which the text is indented.

%v : (only allowed in the entrys “Main Part” and “Refinements” !)

At this point, the corresponding refinements are inserted.

%% : The percent sign itself.

There are several translation tables on the Strux disk. However, these tables are only examples, because every programmer can easily create his or her own tables depending on personal preferences.

3.10.2 Example: Translation of a Loop

With the example of a “while” loop and its conversion into Pascal or C sourcecode, the effect of the control characters should be enlightened. A loop with the condition “a<b” and the loop body “increment a by 3” (see figure 3.6) will be translated. On your disk, you find this example by the

name “Diagrams/Examples/translation example”.

in C: The textfield of the translation table says “while(%t)%n {%b2 }”.

1. text is written until the % symbol: “while(”

2. for %t, the text of the block is written: “a<b”

3. “)” is written.

4. %n starts a new line

5. “ {” is written

6. %b2 means: The body of the loop is inserted. All lines are indented by two characters. The text starts with a new line. In this example, the loop of the body consists of only one action, which is translated with “/* increment a by 3 */”. After insertion of the loop body, a new line is begun.

7. “ }” is written.

The result is:

Figure 3.6: Flowchart for the translation example

while(a<b)
 {
  /* increment a by 3 */
 }

in Pascal: In the translation table, we find the text “WHILE %t DO

BEGIN%b2END;”.

1. “WHILE” is written

2. %t is replaced by “a<b”

3. “DO BEGIN” is written

4. for %b2, the loop of the body is inserted. All lines are indented by two characters. The text starts with a new line. In this example, the loop of the body consists of only one action, which is translated with “{ increment a by 3 }”. After inserting the loop body, a new line is begun.

5. “END;” is written

The result is:

WHILE a<b DO BEGIN
  { increment a by 3 }
END;

Finally, you just have to complete the body of the loop with the command “increment a by 3” in the appropriate language (“a+=3” resp. “a:=a+3”) and the loop is finished (with a comment !).

34 CHAPTER 3. WORKING WITH STRUX

Tutorial

4.1 The Problem

We want to develop a program, that reads a list of numbers (e.g. results of a measurement), calculates the average value and finds the maximum of all values. First, we will design a flowchart and then convert it into a C or Pascal program.

You can find this example on your Strux disk as “Diagrams/Examples/analyze”. However, it is recommended to follow the explanations step by step.

4.2 Developing the Flowchart

1. First, the main structure of the program should be defined. We split the problem into four steps and enter each of them as a block of type “action”. The steps are:

      (a) read results of measurement
     (b) calculate average
      (c) find maximum
     (d) write average and maximum

The result should look like figure 4.1.

2. Now, the block “read results of measurement” should be specified more precisely. Therefore, we click on this block and select the menu item Refinements ≫ Refine Block. An empty working area named “read results of measurement” appears.

Figure 4.1: Top level of the flowchart for the program “analyze”

Figure 4.2: Refinement for “read results of measurement”, first step

(a) we want to start with reading the number of values, this number should be named “n”. So we select the menu item Add ≫ Input… to add a block for the input. As text, we enter “read

number of values (=n)”.

(b) Now, the results themselves should be read. We expect n values to be entered, so we need a loop that will be executed n times and reads one value each time. We use a count loop which we create with by selecting Add ≫ For… Repeat. . .. We enter “for

i from 1 to n” as text for the loop and “read i-th value”

for the action in the loop body. Since the action is actually an input, we have to change the block’s type by selecting the menu item Edit ≫ Modify ≫ Type. . .. For the new type, we choose “Input” and close the requester with “Use”. The flowchart should now look like figure 4.2.

(c) It occurs to us that we want to check if the entered number of values (n) is in the allowed range. The number should be read until it is in the allowed range. We recognize the word “… until” in the previous sentence, so we decide to use a “repeat … until” loop. We click on the block “read number of values (=n)” and select the menu item Add ≫ Repeat… Until. . .. We have to enter the condition of termination, which is “until n>0 and n<=maximum number”. We do not need the action block in the Figure 4.3: Refinement for “read results of measurement”, second step

Figure 4.4: Refinement for “read results of measurement”, complete

loop body, since we have already created that block. So we do not enter any text and select the “Use” button. Now, we have to get the block “read number of values (=n)” into the loop body and delete the “???” block. We do this in five steps:

  i. click on the block “read number of values (=n)”

ii. select menu item Edit ≫ Cut iii. click on the block “???” iv. select menu item Edit ≫ Paste v. select menu item Edit ≫ Erase

To verify the result, have a look at figure 4.4. To get back to the main part, we select the menu item Refinements ≫ Higher Level.

3. Now, we will refine the block “calculate average”. So we click on this block and select the menu item Refinements ≫ Refine Block. To calculate the average, we will first add up all values and then divide the sum by the number of values. This should not be a big problem now, so we will split it into three steps:

Figure 4.5: Refinement for “calculate average”

(a) create an action block with the text “set sum to zero”

(b) create a count loop (“For… Repeat… ”) with the text “for all n values” and the action “add value to sum” in the loop body

(c) create action “average := sum / n”

The flowchart is shown in figure 4.5. By selecting Refinements ≫ Higher Level, we get back to our main program.

4. At last, we refine the block “find maximum”. So we click on it and select Refinements ≫ Refine Block.

To find the maximum, we proceed as follows:

For the beginning, the maximum is set to the first value. Then, every other value is compared with the maximum. If a value is greater than the former maximum, the maximum is set to this value. A look at the flowchart (figure 4.6) helps understanding this algorithm.

(a) First, we create the action “set maximum to first value”.

(b) Then, we add a count loop (“For… Repeat… ”) with the text “For i from 2 to n”. For the action in the loop body, we do not need to enter a text. (Just select the “Use” button.)

(c) Now, we will insert the comparison between each value and the maximum into the loop body. We click on the “???” block and create a decision block with the menu item Add ≫ If Then. . .. For the condition, we enter “i-th value greater than maximum ?” and for the action in the “then” branch “set

maximum to i-th value”.

(d) Finally, we have to get rid of the “???” block by clicking on this block and selecting Edit ≫ Erase.

Figure 4.6: Refinement for “find maximum”

The creation of the flowchart is now finished. With the menu item Project ≫ Save As ≫ Strux-file, you can save it to disk now.

To design the flowchart in another representation as the one by Nassi-Shneiderman which was used in this example, you must perform the same steps, merely some texts would be slightly different.

4.3 Creating a C Program

After having finished the flowchart, we will create a program in the language C. First, we must select the appropriate translation table. So we select the menu item Settings ≫ Translation Table… and select the button “Open… ” in the appearing requester . In the filerequester, we choose the translation table “C” and open it. The table is displayed. We close the requester with “Use”.

Then we select the menu item Project ≫ Save As ≫ Text… to save the flowchart as sourcecode by any name. When looking at this resulting textfile with a texteditor, we see the follwing:

read_results_of_measurement()
{
  do
   {
    /* read number of values (=n) */
   }
  while();  /* while NOT until n>0 and n<=maximum number */
  for(;;) /* for i from 1 to n */
   {
    /* read i-th value */
   }
}

calculate_average()
{
  /* set sum to zero */
  for(;;) /* for all n values */
   {
    /* add value to sum */
   }
  /* average := sum / n */
}
find_maximum()
{
  /* set maximum to first value */
  for(;;) /* for i from 2 to n */
   {
    if()  /* i-th value greater than maximum ? */
     {
      /* set maximum to i-th value */
     }
   }
}
main()
{
  read_results_of_measurement();
  calculate_average();
  find_maximum();
  /* write average and maximum */
}

With this code, we can easily finish our little program by adding some lines:

#define N_MAX 50    /* maximum number of values */
int average,max,     /* average and maximum */
    value[N_MAX],
    n;              /* actual number of values */

read_results_of_measurement()
{
int i;
do
 {
  /* read number of values (=n) */
  printf("Number of values ? ->");
  scanf("%d",&n);
 }
while(!(n>0 && n<N_MAX));  /* while NOT n>0 and n<=maximum number */
for(i=1;i<=n;i++) /* for i from 1 to n */
 {
  /* read i-th value */
  printf("%d. value ? ->",i);
  scanf("%d",&value[i-1]);
 }
}
calculate_average()
{
/* set sum to zero */
int sum=0,i;
for(i=1;i<=n;i++) /* for all n values */
 {
  /* add value to sum */
  sum+=value[i-1];
 }
/* average := sum / n */
average=sum/n;
}
find_maximum()
{
int i;
/* set maximum to first value */
max=value[0];
for(i=2;i<=n;i++) /* for i from 2 to n */
 {
  if(value[i-1]>max)  /* i-th value greater than maximum ? */
   {
    /* set maximum to i-th value */
    max=value[i-1];

     }
   }
}
main()
{
  read_results_of_measurement();
  calculate_average();
  find_maximum();
  /* write average and maximum */
  printf("The average is %d, the maximum is %d.\n",average,max);
}

This program can be compiled and executed.

4.4 Creating a Pascal Program

The generation of a Pascal program from the flowchart is similar to the conversion into C. First, the translation table “Pascal” is loaded and then the flowchart is saved as text:

PROGRAM analyze (INPUT,OUTPUT);
PROCEDURE read_results_of_measurement;
BEGIN
  REPEAT
    { read number of values (=n) }
  UNTIL until n>0 and n<=maximum number;
  FOR for i from 1 to n DO BEGIN
    { read i-th value }
  END;
END;
PROCEDURE calculate_average;
BEGIN
  { set sum to zero }
  FOR for all n values DO BEGIN
    { add value to sum }
  END;
  { average := sum / n }

END;
PROCEDURE find_maximum;
BEGIN
  { set maximum to first value }
  FOR for i from 2 to n DO BEGIN
    IF i-th value greater than maximum ? THEN
     BEGIN
      { set maximum to i-th value }
     END
  END;
END;
{ main part: }
BEGIN
  read_results_of_measurement;
  calculate_average;
  find_maximum;
  { write average and maximum }
END.

With this text, you can easily create the following program:

PROGRAM analyze (INPUT,OUTPUT);
CONST MAX_N=50;   { maximum number of values }
VAR n,average,max : INTEGER;  { actual number of values, average and maximum }
    value : ARRAY[1..MAX_N] OF INTEGER;

PROCEDURE read_results_of_measurement;
VAR i : INTEGER;
BEGIN
  REPEAT
    { read number of values (=n) }
    write('number of values ? ->');
    readln(n);
  UNTIL (n>0) and (n<=MAX_N);
  FOR i:=1 TO n DO BEGIN

  { read i-th value }
  write(i,'. value ? ->');
  readln(value[i]);
END;
END;
PROCEDURE calculate_average;
VAR sum,i : INTEGER;
BEGIN
{ set sum to zero }
sum:=0;
FOR i:=1 TO n DO BEGIN  { for all n values }
  { add value to sum }
  sum:=sum+value[i];
END;
average := sum DIV n;
END;
PROCEDURE find_maximum;
VAR i : INTEGER;
BEGIN
{ set maximum to first value }
max:=value[1];
FOR i:=2 TO n DO BEGIN
  IF value[i]>max THEN
   BEGIN
    { set maximum to i-th value }
    max:=value[i];
   END
END;
END;
{ main part: }
BEGIN
read_results_of_measurement;
calculate_average;
find_maximum;
{ write average and maximum }
writeln('The average is ',average,', the maximum is ',max);
END.

Miscellaneous

5.1 Title Bars

You find some information in the title bars of the Strux window and the screen on which the window is opened.

5.1.1 … of the Window

The text depends on whether the main part or a refinement of the flowchart is displayed:

main part: The type of representation is displayed, this may be either “Flowchart”, “Nassi-Shneiderman” or “Pseudocode”.

refinement: The text of the refined block is displayed.

5.1.2 … of the Screen

From left to right, the following information is presented:

• First the name of this program (“Strux”) to provide better orientation when several programs are running simultaneously.

• The name of the current flowchart. This is the name by which the diagram has been opened or saved. Only saving as a Strux-file is considered.

• While you are marking a range, a “M” is displayed. (see 3.2.5)

• A star (“∗”) indicates that the flowchart has been changed since the last time it has been saved.

5.2 Tooltypes

Via the tooltypes of the Strux icon, you can make some further settings. You will find a detailed description how to set and change the tooltypes in your Workbench manual.

Strux recognizes the following tooltypes:

FILE: You can specify a name of a flowchart that will be opened automatically after starting Strux.

SETTINGS: Here you can define a settings file, which will be used instead of the default file “strux.prefs”.

So, if you save your settings with the name “my.prefs” (see 3.9.6) and set the tooltype “SETTINGS=my.prefs”, Strux will use these setting each time you start it.

PUBSCREEN: You can specify the name of a public screen, on which the Strux window should be opened. For more details about public screens, see 3.9.2. If the specified public screen does not exist, Strux will open its window on the Workbench.

LANGUAGE: When selecting “LANGUAGE=deutsch” or nothing, all program texts are in german. With “LANGUAGE=english”, you get english texts.

SPRACHE: This tooltype is the same as “LANGUAGE”.

5.3 Starting from the Shell

The pattern for the possible arguments can be displayed by typing “strux ?”. It is:

     FILE,PUBSCREEN/K,SETTINGS/K,LANGUAGE=SPRACHE/K

The arguments have the same meaning as the tooltypes of the icon. They can be specified in any order.

FILE: You can specify a name of a flowchart that will be opened immediately when you start Strux. This name can be typed without the keyword “FILE”. E.g. by typing “strux my flowchart”, Strux will start and open the diagram “my flowchart”.

PUBSCREEN: You can specify the name of a public screen, on which the Strux window should be opened.

Example: When you start Strux by “strux PUBSCREEN CygnusEdScreen1”, the Strux window is opened on the CygnusEd screen. (Presuming that CygnusEd is running and has opened a public screen, of course)

SETTINGS: Here you can define a settings file, which will be used instead of the default file “strux.prefs”.

LANGUAGE: When typing “LANGUAGE deutsch” or nothing, all program texts are in german. With “LANGUAGE english”, you get english texts.

SPRACHE: This argument is the same as “LANGUAGE”.

5.4 Support

If you have problems with Strux that cannot be solved with this manual, you can address yourself to this address:

PCP Hard- & Software Andreas Günther Alfener Weg 10 D-33100 Paderborn Germany

Bug reports, suggestions of improvements to Strux or ideas for other programs are also welcome.

Please note: Only registered users will get help. So do not forget to mail back the enclosed registration card !

5.5 License Agreement

When using Strux, you agree to the following terms. If you do not agree to these terms, return the undamaged package with the diskette seal intact to the place of purchase and your money will be refund.

Copyright: The program and the related documentation are copyrighted. You may not copy the program or its documentation except as provided in this agreement.

License: You have the non-exclusive right to use the enclosed program on a single computer. You may not modify or translate the program and the documentation. You may not distribute copies of the program and documentation to others ! If you transfer the program and the documentation, you have to transfer or destroy all your backup copies.

Back-up: You are allowed to make one copy of the program for back-up purposes.

Disclaimer: The program is provided “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the results and performance is assumed by the user.

Appendix A

Keyboard Shortcuts

All keybord shortcuts for operating with the menus are listed on the next page for a quick reference. Pressing these keys together with the right “Amiga”-key ( A ) has the same effect as selecting the corresponding menu item.

menu  key menu function
Project  N New…
O Open Strux-file…
S Save
A Save as Strux-file…
J Save as text…
G Save as image…
P Print all
Q Quit Strux…
Edit  X Cut
C Copy
V Paste
T Modify text…
Y Modify type…
M Mark range
Refinements D Refine block
U Higher level
K Top level
Z Show ?
L Set main refinement
Add  0 Action…
1 If Then…
2 If Then Else…
3 Select of…
4 Case…
5 Default/Else…
W While…
R Repeat… Until…
F For… Repeat…
E Repeat Forever…
6 Exit
B Subroutine…
9 Program…
I Input…
H Output…
7 Parallel…
8 Process…
Settings  ! Diagram…
( Screen…
) Program…
< Translation table…

Appendix B

Graphical Representations

A survey of the used symbols and keywords is given in this appendix. For each construct, all three types of representation are shown in the order

Nassi-Shneiderman - Flowchart - Pseudocode Action

If Then If Then Else

Select Of

While

Repeat Until For Repeat

Repeat Forever Exit Subroutine Program Input Output

Parallel